
import { StudentService } from '../service/student.service';
import { Controller, Get, Inject, Param } from "@nestjs/common";

@Controller('student')
export class StudentCotroller {
    //通过构造函数注入StudentService
    // constructor(private readonly studentService: StudentService) {//service注入到controller
    // }
    //属性注入
    @Inject()
    private studentService:StudentService
    //处理get请求
    @Get()
    findAll() {
        //直接使用注入的studentService
        return this.studentService.findAll();

    }
    //找某个人的信息
    @Get(':id')
    findOne(@Param('id') id: string) {
        return this.studentService.findOne(+id);//转为number类型
    }

}